/*
package com.gaofei.sysmanager.controller;


import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.gaofei.sysmanager.common.CommonResult;
import com.gaofei.sysmanager.domain.Supplier;
import com.gaofei.sysmanager.service.ISupplierService;
import com.wjj.domain.FileResult;
import com.wjj.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.ListenableFutureCallback;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;


*/
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wjj
 * @since 2021-11-02
 *//*

@RestController
@RequestMapping("/supplier")
public class SupplierController {

    @Autowired
    private ISupplierService supplierService;

    @Autowired
    private KafkaTemplate kafkaTemplate;

    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private FileService fileService;

    //查看我添加的所有 供应商  (es查询列表 分页 高亮)
    @RequestMapping("/toSaveSupplier")
    public CommonResult selectSupplier(@RequestBody Supplier supplier){
//        String post = HttpUtil.post("http://localhost:9001/supplier/saveSupplier", "");
        Map<String,Object> map = new HashMap<>();
        map.put("code",supplier.getCode());
        map.put("personPhone",supplier.getPersonPhone());
        map.put("supplierAs",supplier.getSupplierAs());
        map.put("supplierCoding",supplier.getSupplierCoding());
        map.put("supplierName",supplier.getSupplierName());

        String post = HttpUtil.get("http://localhost:9001/supplier/saveSupplier", map);
        return CommonResult.success(post,"接口");
    }


    @RequestMapping("/saveSupplier")
    public CommonResult saveSupplier( Supplier supplier){

        boolean save = supplierService.save(supplier);

        //将对象转换成json字符串
        String jsonString = JSON.toJSONString(supplier);
        //卡夫卡发送到监听器
        ListenableFuture send = kafkaTemplate.send("1904", "supplier", jsonString);
        redisTemplate.expire("supper",3,TimeUnit.SECONDS);
        redisTemplate.opsForValue().set("supper","supper");
        send.addCallback(new ListenableFutureCallback() {
            @Override
            public void onFailure(Throwable throwable) {
                System.out.println("发送失败,重新发送!!!");
                kafkaTemplate.send("supplier",jsonString);
            }

            @Override
            public void onSuccess(Object o) {
                System.out.println("发送成功!!!");
            }
        });

//        将添加对象转换成字符串
        */
/*String supplierString = JSON.toJSONString(supplier);
        ListenableFuture<SendResult<String,String>> send = kafkaTemplate.send("1904","supplier", supplierString);
        redisTemplate.expire("supplier",3, TimeUnit.SECONDS);
        redisTemplate.opsForValue().set("supplier","supplier");
        send.addCallback(new ListenableFutureCallback(){

            //消息发送成功
            @Override
            public void onSuccess(Object o) {
                System.out.println("消息发送成功!!!");
            }

            //消息发送失败
            @Override
            public void onFailure(Throwable throwable) {
                System.out.println("消息发送失败!!!!");
                //重新发送
                kafkaTemplate.send("1904",supplierString);
            }
        });
        System.out.println("供应商对象 is : "+supplier);
        if(save){
            System.out.println("添加供应商成功!!!");
        }else{
            System.out.println("添加供应商失败!!!");
        }*//*

        return CommonResult.success(save,"save is ok !!!");
    }

    @RequestMapping("updateImp")
    public  CommonResult updateImp(MultipartFile[] file){
        List<FileResult>  upload = fileService.upload(file);

        FileResult fileResult = upload.get(0);
        String fileName = fileResult.getFileName();
        return CommonResult.success(upload,"图片上传成功");
    }
}

*/
